{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a13545fc-06a1-4028-96ce-5355fe8b51ba",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "34135c8f",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "a = torch.tensor(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "65009ef5-d0fa-46da-8394-b160856d11d1",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.LongTensor\n"
     ]
    }
   ],
   "source": [
    "print(a.type())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "986c7dfb",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'torch.Tensor'>\n"
     ]
    }
   ],
   "source": [
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0f50d738",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cpu\n"
     ]
    }
   ],
   "source": [
    "print(a.device)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "82766a02",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([])\n",
      "torch.Size([])\n"
     ]
    }
   ],
   "source": [
    "print(a.shape)\n",
    "print(a.size())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "29eade74",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(isinstance(a,torch.LongTensor))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d998f278",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "#查看维度\n",
    "print(a.dim())\n",
    "print(len(a.shape))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "cee3e824",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1, 2, 3, 4])\n",
      "1\n",
      "torch.LongTensor\n",
      "cpu\n",
      "torch.Size([4])\n"
     ]
    }
   ],
   "source": [
    "b =torch.tensor([1,2,3,4])\n",
    "print(b)\n",
    "print(b.dim())\n",
    "print(b.type())\n",
    "print(b.device)\n",
    "print(b.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "153fbb9a",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n"
     ]
    }
   ],
   "source": [
    "c = torch.tensor([[1,2,3,4],[5,6,7,8,]])\n",
    "print(c.numel())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2e5bcc11",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "#取a中的值\n",
    "print(a.item())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "72f3f706",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1, 2, 3, 4], dtype=torch.int32)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a=np.array([1,2,3,4])\n",
    "b=torch.from_numpy(a)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3d21ee9a",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[1., 1., 1.],\n",
       "        [1., 1., 1.],\n",
       "        [1., 1., 1.]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c=torch.ones(3,3)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "1e8e1be3",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0., 0., 0., 0.],\n",
       "        [0., 0., 0., 0.],\n",
       "        [0., 0., 0., 0.],\n",
       "        [0., 0., 0., 0.]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c=torch.zeros(4,4)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "80bd36ed",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[1., 0., 0., 0.],\n",
       "        [0., 1., 0., 0.],\n",
       "        [0., 0., 1., 0.],\n",
       "        [0., 0., 0., 1.]])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = torch.eye(4,4)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "decc89a8",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([1, 3, 5, 7, 9])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c=torch.arange(1,10,2)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5e678118",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([ 1.,  4.,  7., 10.])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = torch.linspace(1,10,4)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "c32828ae",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[1700867382, 1714251108,  825701988],\n",
       "        [ 960051251,  775446840, 1667594341]], dtype=torch.int32)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a= torch.empty((2,3),dtype = torch.int32,device = 'cpu' )\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "c39c53bd",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[6.6460e+22, 2.0471e+23, 2.6661e-09],\n",
       "        [1.7664e-04, 4.1923e-11, 7.1450e+31]])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=torch.Tensor(2,3)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d04c4feb",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.DoubleTensor\n",
      "torch.DoubleTensor\n"
     ]
    }
   ],
   "source": [
    "a = torch.Tensor(2,3)\n",
    "torch.set_default_tensor_type(torch.DoubleTensor)\n",
    "b =torch.Tensor(2,3)\n",
    "print(a.type())\n",
    "print(b.type())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5bac96ca",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-0.5937,  0.0217, -0.5269],\n",
       "        [ 0.0660, -1.3618,  1.0921],\n",
       "        [-2.2099,  2.0430,  1.6424]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=torch.randn(3,3)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3b19c1e0",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([0, 3, 9, 1, 7, 8, 2, 5, 6, 4])\n"
     ]
    }
   ],
   "source": [
    "a=torch.randperm(10)\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "85b62d38",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([4, 4])\n"
     ]
    }
   ],
   "source": [
    "a = torch.Tensor(2,3,4,4)\n",
    "print(a[0][1].shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e9a3b425",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 0.4405, -0.6508, -0.1016],\n",
      "        [ 2.2877, -1.0803, -0.4683],\n",
      "        [-0.2314,  0.4321, -1.6464]])\n",
      "tensor([[ True, False, False],\n",
      "        [False,  True, False],\n",
      "        [False, False,  True]])\n",
      "tensor([ 0.4405, -1.0803, -1.6464])\n"
     ]
    }
   ],
   "source": [
    "#torch.masked_select() 模板取\n",
    "a = torch.randn(3,3)\n",
    "mask =torch.eye(3,3,dtype = torch.bool)\n",
    "print(a)\n",
    "print(mask)\n",
    "c=torch.masked_select(a,mask)\n",
    "print (c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6ab343bb",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 0.4034,  0.4050,  0.0881],\n",
      "        [ 0.2421,  0.6888,  0.9765],\n",
      "        [ 1.1862, -0.5996,  0.2882]])\n",
      "tensor([0, 2, 4, 6])\n",
      "tensor([0.4034, 0.0881, 0.6888, 1.1862])\n"
     ]
    }
   ],
   "source": [
    "#torch.take\n",
    "a = torch.randn(3,3)\n",
    "b = torch.tensor([0,2,4,6])\n",
    "c =torch.take(a,b)\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f42c06f",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 改变维度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "98b9a597",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([4, 3, 32, 32])\n",
      "torch.Size([4, 32, 32, 3])\n"
     ]
    }
   ],
   "source": [
    "#transpose（）两个维度互换\n",
    "a = torch.rand(4,3,32,32)\n",
    "b = a.transpose(1,3)\n",
    "print(a.shape)\n",
    "print(b.shape)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "3cf932e4",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([4, 3, 32, 32])\n",
      "torch.Size([4, 32, 32, 3])\n"
     ]
    }
   ],
   "source": [
    "#permute 多个维度重新排列\n",
    "a =torch.rand(4,3,32,32)\n",
    "b = a.permute(0,2,3,1)\n",
    "print(a.shape)\n",
    "print(b.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "b87e4ee7",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([4, 3, 32, 32])\n",
      "torch.Size([4, 3, 1024])\n",
      "torch.Size([4, 3072])\n",
      "torch.Size([4, 3, 4, 8, 4, 8])\n",
      "torch.Size([2, 2, 3, 4, 8, 32])\n"
     ]
    }
   ],
   "source": [
    "#.view .reshape\n",
    "a = torch.rand(4,3,32,32)\n",
    "b = a.view(4,3,32*32)\n",
    "c =a.view(4,-1)\n",
    "d = a.view(4,3,4,8,4,8)\n",
    "print(a.shape)\n",
    "print(b.shape)\n",
    "print(c.shape)\n",
    "print(d.shape)\n",
    "h = a.transpose(1,3).contiguous().view(2,2,3,4,8,32)\n",
    "print(h.shape)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c4f596ab",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([2, 4, 3, 32])\n",
      "torch.Size([1, 2, 4, 3, 32])\n",
      "torch.Size([2, 4, 3, 32])\n"
     ]
    }
   ],
   "source": [
    "#unsqueeze() 扩张(升维)\n",
    "a = torch.randn(2,4,3,32)\n",
    "b = a.unsqueeze(0)\n",
    "print(a.shape)\n",
    "print(b.shape)\n",
    "#squeeze 降维 只能降1的维度\n",
    "c =a.squeeze(1)\n",
    "print(c.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "9e88f52f",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([2, 6, 32, 32])\n",
      "torch.Size([4, 2, 64, 64])\n"
     ]
    }
   ],
   "source": [
    "#expand（） repeat（）\n",
    "a= torch.rand(2,1,32,32)\n",
    "b = a.expand(2,6,32,32)\n",
    "print(b.shape)\n",
    "c = a.repeat(2,2,2,2)\n",
    "print(c.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d1e849f0",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "70c682c7",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 拼接与拆分\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1387a755",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([3, 32, 8])\n",
      "torch.Size([6, 32, 8])\n",
      "torch.Size([9, 32, 8])\n"
     ]
    }
   ],
   "source": [
    "#cat()\n",
    "a = torch.rand(3,32,8)\n",
    "b = torch.rand (6,32,8)\n",
    "c =torch.cat([a,b],dim=0)\n",
    "print(a.shape)\n",
    "print (b.shape)\n",
    "print(c.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "aa78de29",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([3, 3, 224, 224])\n",
      "torch.Size([3, 3, 224, 224])\n",
      "torch.Size([3, 3, 3, 224, 224])\n"
     ]
    }
   ],
   "source": [
    "#stack()\n",
    "a = torch.rand(3,3,224,224)\n",
    "b = torch.rand(3,3,224,224)\n",
    "f =torch.rand(3,3,224,224)\n",
    "c = torch.stack([a,b,f],dim = 0)\n",
    "print(a.shape)\n",
    "print(b.shape)\n",
    "print(c.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "abfd82b5",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "torch.Size([1, 3, 224, 224])\n"
     ]
    }
   ],
   "source": [
    "#拆分 split()\n",
    "a = torch.rand(3,3,224,224)\n",
    "b = torch.split(a,1,0)\n",
    "print(len(b))\n",
    "print(b[0].shape)\n",
    "#print(b[2].shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5348a383",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([2, 3, 224, 224])\n",
      "torch.Size([1, 3, 224, 224])\n"
     ]
    }
   ],
   "source": [
    "#chunk\n",
    "a = torch.rand(3,3,224,224)\n",
    "b = torch.chunk(a,2,0)\n",
    "print(b[0].shape)\n",
    "print(b[1].shape)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c9f4520b",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 运算与统计 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "a9ab86dc",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0.9349, 0.3391, 0.5035, 0.0167],\n",
      "        [0.8169, 0.6895, 0.1925, 0.4441],\n",
      "        [0.3555, 0.3622, 0.0591, 0.2693]])\n",
      "tensor([0.3408, 0.5678, 0.9452, 0.7331])\n",
      "tensor([[1.2757, 0.9069, 1.4488, 0.7498],\n",
      "        [1.1576, 1.2573, 1.1377, 1.1772],\n",
      "        [0.6962, 0.9300, 1.0043, 1.0024]])\n",
      "tensor([[1.2757, 0.9069, 1.4488, 0.7498],\n",
      "        [1.1576, 1.2573, 1.1377, 1.1772],\n",
      "        [0.6962, 0.9300, 1.0043, 1.0024]])\n"
     ]
    }
   ],
   "source": [
    "a = torch.rand(3,4)\n",
    "b = torch.rand(4)\n",
    "c = a+b\n",
    "d = torch.add(a,b)\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "5212d51c",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor(3.1416)\n",
      "tensor(4.)\n",
      "tensor(3.)\n",
      "tensor(3.)\n",
      "tensor(3.)\n",
      "tensor(0.1416)\n"
     ]
    }
   ],
   "source": [
    "a =torch.tensor(3.1415926)\n",
    "b = a.ceil()\n",
    "c = a.floor()\n",
    "d = a.round() #四舍五入\n",
    "e = a.trunc() #取整数\n",
    "f = a.frac()#取小数\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)\n",
    "print(d)\n",
    "print(e)\n",
    "print(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "144d2d5b",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[13.0007, 14.4370, 16.1596],\n",
      "        [17.7595,  8.7957, 18.2932],\n",
      "        [12.6117, 15.7598,  4.7444]])\n",
      "tensor([[10.0000, 10.0000, 10.0000],\n",
      "        [10.0000,  8.7957, 10.0000],\n",
      "        [10.0000, 10.0000,  4.7444]])\n",
      "tensor([[13.0007, 14.0000, 14.0000],\n",
      "        [14.0000,  8.7957, 14.0000],\n",
      "        [12.6117, 14.0000,  7.0000]])\n"
     ]
    }
   ],
   "source": [
    "#.clamp()\n",
    "a = torch.rand(3,3)*20\n",
    "b = a.clamp(0,10)\n",
    "c = a.clamp(7,14)\n",
    "print(a)\n",
    "print(b)\n",
    "print(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2eebba21",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "#torch.nn#专门为神经网络设计的模块化接口，用来定义神经网络\n",
    "import torch\n",
    "#torch.nn.function #包含神经网路中的常用函数\n",
    "import torch.nn.functional as F\n",
    "import torch.nn as nn"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pytorch",
   "language": "python",
   "name": "pytorch"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}